/*     */ package cc.s2m.web.s2mBlog.service.impl;
/*     */ 
/*     */ import cc.s2m.util.BeanConverter;
/*     */ import cc.s2m.util.Method;
/*     */ import cc.s2m.util.Page;
/*     */ import cc.s2m.util.PageUtil;
/*     */ import cc.s2m.web.s2mBlog.dao.BaseDao;
/*     */ import cc.s2m.web.s2mBlog.vo.VO;
/*     */ import com.google.common.collect.Maps;
/*     */ import java.io.Serializable;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ public abstract class BaseServiceImpl<T, DAO extends BaseDao<T, PK>, PK extends Serializable>
/*     */ {
/*     */   protected abstract DAO getDao();
/*     */ 
/*     */   public int deleteByPrimaryKey(PK id)
/*     */   {
/*  22 */     return getDao().deleteByPrimaryKey(id);
/*     */   }
/*     */   public int delete(T condition, Map<String, Object> map) {
/*  25 */     if (map == null) {
/*  26 */       map = Maps.newHashMap();
/*     */     }
/*  28 */     map.putAll(BeanConverter.toMap(condition, false));
/*  29 */     return getDao().delete(map);
/*     */   }
/*     */   public int insert(T record) {
/*  32 */     return getDao().insert(record);
/*     */   }
/*     */   public int insertSelective(T record) {
/*  35 */     return getDao().insertSelective(record);
/*     */   }
/*     */   public T selectByPrimaryKey(PK id) {
/*  38 */     return getDao().selectByPrimaryKey(id);
/*     */   }
/*     */   public T getByCondition(T record) {
/*  41 */     Map params = new HashMap();
/*  42 */     params.put("condition", record);
/*  43 */     return getDao().getByCondition(params);
/*     */   }
/*     */   public T getByCondition(T record, VO vo) {
/*  46 */     Map params = new HashMap();
/*  47 */     params.put("condition", record);
/*  48 */     params.put("vo", vo);
/*  49 */     return getDao().getByCondition(params);
/*     */   }
/*     */   public T getByCondition(T record, VO vo, String orderBy) {
/*  52 */     Map params = new HashMap();
/*  53 */     params.put("condition", record);
/*  54 */     params.put("vo", vo);
/*  55 */     params.put("orderBy", orderBy);
/*  56 */     return getDao().getByCondition(params);
/*     */   }
/*     */   public int updateByPrimaryKeySelective(T record) {
/*  59 */     return getDao().updateByPrimaryKeySelective(record);
/*     */   }
/*     */   public int updateByCondition(T record, T condition) {
/*  62 */     Map params = new HashMap();
/*  63 */     params.put("entity", record);
/*  64 */     params.put("condition", condition);
/*  65 */     return getDao().updateByCondition(params);
/*     */   }
/*     */   public int updateByPrimaryKey(T record) {
/*  68 */     return getDao().updateByPrimaryKey(record);
/*     */   }
/*     */   public List<T> getList(T condition, Map<String, Object> map) {
/*  71 */     if (map == null) {
/*  72 */       map = Maps.newHashMap();
/*     */     }
/*  74 */     if (condition != null) {
/*  75 */       map.putAll(BeanConverter.toMap(condition, false));
/*     */     }
/*  77 */     return getDao().getList(map);
/*     */   }
/*     */   public int getCount(Map<String, ?> map) {
/*  80 */     return getDao().getCount(map);
/*     */   }
/*     */ 
/*     */   public Page<T> getPage(int pageNumber, int maxRows, String url, Map<String, Object> map)
/*     */   {
/*  94 */     String params = Method.getQuery(map);
/*  95 */     int totalRow = getDao().getCount(map);
/*  96 */     Page page = new Page(maxRows, url, params);
/*  97 */     page.setCurPage(pageNumber);
/*  98 */     page = PageUtil.createPage(page, totalRow);
/*  99 */     map.put("pageBeginIndex", Integer.valueOf(page.getBeginIndex()));
/* 100 */     map.put("pageSize", Integer.valueOf(page.getPageSize()));
/* 101 */     page.setResult(getDao().getList(map));
/* 102 */     return page;
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.service.impl.BaseServiceImpl
 * JD-Core Version:    0.6.1
 */